package com.firefly.admin.common.handle;

import com.firefly.admin.common.enums.ResultCodeEnum;
import com.firefly.admin.common.utils.ResponseUtil;
import com.firefly.admin.common.vo.Result;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class RestAccessDeniedHandler implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) {
        ResponseUtil.returnFail(response, Result.getResult(ResultCodeEnum.FORBIDDEN));
    }
}
